home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / VPOJAVA.DLL / SOURCE / ABOUT_DIALOG next >
Text File  |  1998-12-10  |  4KB  |  149 lines

  1. /*
  2.     A basic extension of the java.awt.Dialog class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class AboutDialog extends Dialog {
  8.  
  9.     public AboutDialog(Frame parent, boolean modal)
  10.     {
  11.         super(parent, modal);
  12.  
  13.         // This code is automatically generated by Visual Cafe when you add
  14.         // components to the visual environment. It instantiates and initializes
  15.         // the components. To modify the code, only use code syntax that matches
  16.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  17.         // parse your Java file into its visual environment.
  18.         
  19.         //{{INIT_CONTROLS
  20.         setLayout(null);
  21.         setSize(249,150);
  22.         setVisible(false);
  23.         label1.setText("A Basic Java Application");
  24.         add(label1);
  25.         label1.setBounds(40,35,166,21);
  26.         okButton.setLabel("OK");
  27.         add(okButton);
  28.         okButton.setBounds(95,85,66,27);
  29.         setTitle("AWT Application - About");
  30.         //}}
  31.         
  32.         //{{REGISTER_LISTENERS
  33.         SymWindow aSymWindow = new SymWindow();
  34.         this.addWindowListener(aSymWindow);
  35.         SymAction lSymAction = new SymAction();
  36.         okButton.addActionListener(lSymAction);
  37.         //}}
  38.  
  39.     }
  40.     
  41.     public AboutDialog(Frame parent, String title, boolean modal)
  42.     {
  43.         this(parent, modal);
  44.         setTitle(title);
  45.     }
  46.  
  47.     public void addNotify()
  48.     {
  49.         // Record the size of the window prior to calling parents addNotify.
  50.                 Dimension d = getSize();
  51.  
  52.         super.addNotify();
  53.  
  54.         // Only do this once.
  55.         if (fComponentsAdjusted)
  56.             return;
  57.  
  58.         // Adjust components according to the insets
  59.         Insets insets = getInsets();
  60.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  61.         Component components[] = getComponents();
  62.         for (int i = 0; i < components.length; i++)
  63.         {
  64.             Point p = components[i].getLocation();
  65.             p.translate(insets.left, insets.top);
  66.             components[i].setLocation(p);
  67.         }
  68.  
  69.         // Used for addNotify check.
  70.         fComponentsAdjusted = true;
  71.     }
  72.  
  73.     public void setVisible(boolean b)
  74.     {
  75.         if (b)
  76.         {
  77.             Rectangle bounds = getParent().getBounds();
  78.             Rectangle abounds = getBounds();
  79.  
  80.             setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
  81.                  bounds.y + (bounds.height - abounds.height)/2);
  82.         }
  83.  
  84.         super.setVisible(b);
  85.     }
  86.  
  87.     //{{DECLARE_CONTROLS
  88.     java.awt.Label label1 = new java.awt.Label();
  89.     java.awt.Button okButton = new java.awt.Button();
  90.     //}}
  91.     
  92.     // Used for addNotify check.
  93.     boolean fComponentsAdjusted = false;
  94.  
  95.     class SymAction implements java.awt.event.ActionListener
  96.     {
  97.         public void actionPerformed(java.awt.event.ActionEvent event)
  98.         {
  99.             Object object = event.getSource();
  100.             if (object == okButton)
  101.                 okButton_ActionPerformed(event);
  102.         }
  103.     }
  104.  
  105.     void okButton_ActionPerformed(java.awt.event.ActionEvent event)
  106.     {
  107.         // to do: code goes here.
  108.              
  109.         okButton_ActionPerformed_Interaction1(event);
  110.     }
  111.  
  112.  
  113.     void okButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  114.     {
  115.         try {
  116.             this.dispose();
  117.         } catch (Exception e) {
  118.         }
  119.     }
  120.  
  121.  
  122.     class SymWindow extends java.awt.event.WindowAdapter
  123.     {
  124.         public void windowClosing(java.awt.event.WindowEvent event)
  125.         {
  126.             Object object = event.getSource();
  127.             if (object == AboutDialog.this)
  128.                 AboutDialog_WindowClosing(event);
  129.         }
  130.     }
  131.  
  132.     void AboutDialog_WindowClosing(java.awt.event.WindowEvent event)
  133.     {
  134.         // to do: code goes here.
  135.              
  136.         AboutDialog_WindowClosing_Interaction1(event);
  137.     }
  138.  
  139.  
  140.     void AboutDialog_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
  141.     {
  142.         try {
  143.             this.dispose();
  144.         } catch (Exception e) {
  145.         }
  146.     }
  147.  
  148. }
  149.